﻿using System.IO;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using NLog.Web;

namespace WebAPI_QiSiMealSystem
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //CreateWebHostBuilder(args).Build().Run();
            var logger = NLogBuilder.ConfigureNLog("Nlog.config").GetCurrentClassLogger();
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureLogging(logging =>
                {
                    logging.ClearProviders(); //移除已经注册的其他日志处理程序
                    logging.SetMinimumLevel(LogLevel.Trace); //设置最小的日志级别
                })
                .ConfigureKestrel((context, options) =>
                {
                    options.Listen(IPAddress.Any, 8082, listenOptions =>
                    {
                        var pfxFile = Path.Combine(Directory.GetCurrentDirectory(), "xxx.pfx");
                        //password 填写申请的密钥
                        var certificate = new X509Certificate2(pfxFile, "xxx");
                        listenOptions.UseHttps(certificate);
                    });
                })
                .UseStartup<Startup>();
    }
}
